<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>我的钱包</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>
</head>
<body>
<section class="commission-area">
    <label class="commission-title">总金额(元-包含现金收入)</label>
    <label class="commission-number">
        <span id="getMoneyTotalMonth">0</span>
        <img src="../../img/eye.png" class="eyes iconfont" style="border-right: 20px">
    </label>
    <div class="commission-tab">
        <ul>
            <li class="w50 rline">
                <span class="gray">可提现金额(元)</span>
                <span class="font16 red" id="getMoney">0</span>
            </li>
            <li class="w50">
                <span class="gray">保证金金额(元)</span>
                <span class="font16 red" id="bzj">0</span>
            </li>
        </ul>
    </div>
</section>
<section class="subtitle p15 mt164 p15r">
    本月收入(元-包含现金收入):<span class="red" id="getMoneyMonth">0</span>
    <i class="iconfont rightsmallicon">&#xe6d8;</i>
    <label class="right" id="monthShow">2017/05</label>
    <!--月份筛选-->
    <div class="customer_popuparea">
        <div class="dropbox" id="dropbox">
            <div class="dropitem">2017年5月<i class="iconfont rightsmallicon_red">&#xe6da;</i></div>
        </div>
    </div>
    <!--END-->
</section>
<section class="itemgroup p15 mb56" id="capitalListHtmlId">
	<div class="twoitem">
        <label class="itemname">
            收益(订单编号:12333313333)
            <span class="green right">+0</span>
        </label>
        <label class="itemsubname">2017/4/5 12:59:59</label>
    </div>
</section>
<section class="bottomarea">
    <button type="button" class="btn bottomonebtn" onclick="withdrawalsView()">提现</button>
    <!--<button type="button" style="display:none;" class="btn bottomone2btn right">充值</button>-->
</section>
<script type="text/javascript">
    $(function () {
        //token验证
        checkDriverToken();
    });
    var totalMoneyButbzj = 0;
    var canGetMoney = 0;
    var monthDate = GetArgsFromHref("monthDate");
    $(function () {
        
        var url = _global.serverHost + "/capital/driver/list.htm";
        var data = {monthDate: monthDate, driverUuid: getCookie("driverUuid")};
        _callAjaxRequest(url, data, startBidBack);


        function startBidBack(data) {
        		canGetMoney = data.totalCapital.getMoney;
            $("#getMoney").html(data.totalCapital.getMoney);
            totalMoneyButbzj = data.totalCapital.getMoney;
            $("#getMoneyTotalMonth").html(data.totalCapital.totalMoneyButbzj);
            var bzj="0";
            if(data.bzj!=null && ""!=data.bzj){
            	bzj=data.bzj;
            }
            $("#bzj").html(bzj);
            $("#getMoneyMonth").html(data.totalCapital.getMoneyMonth);
            $("#monthShow").html(data.queryMap.monthDate);

            var dropbox = "";
            for (var a = 0; a < data.monthList.length; a++) {
                var selected_css = '';
                if (data.queryMap.monthDate == data.monthList[a].monthDateId) selected_css = '<i class="iconfont rightsmallicon_red">&#xe6da;</i>';
                dropbox = dropbox + '<div class="dropitem" onclick="monthCapital(\'' + data.monthList[a].monthDateId + '\')">' +
                        data.monthList[a].monthDate + selected_css + '</div>';
            }
            $(".customer_popuparea").toggle();
            $("#dropbox").html(dropbox);

            var twoitem = "";
            for (var i = 0; i < data.capitalList.length; i++) {
                var waybillNum = "";
                var amount = "";
                if (data.capitalList[i].waybillNum != "" && data.capitalList[i].waybillNum != null)
                    waybillNum = "(订单:" + data.capitalList[i].waybillNum + ")";
                if (data.capitalList[i].amount < 0) {
                    amount = "red";
                } else {
                    amount = "green";
                }
                var flag = "";
                if (data.capitalList[i].amount > 0) flag = "+"
                var desc = "";
                if(data.capitalList[i].capitalDesc == '运费收益'){
                	desc = (data.capitalList[i].waybillsource+"下单:"+data.capitalList[i].paytype);	
                }

                twoitem = twoitem + '<div class="twoitem"><label class="itemname">' + data.capitalList[i].capitalDesc
                        + waybillNum + '<span class="right ' + amount + '">' + flag + data.capitalList[i].amount + "</span></label>" +
                        "<label class=\"itemsubname\">" + data.capitalList[i].createDate+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+ desc
                        + "</label></div>";
            }
            $(".twoitem").html(twoitem);
        }
    })

    function monthCapital(monthDateId) {
        window.location.href = "../wallet/index.html?monthDate=" + monthDateId;
    }

    function withdrawalsView() {
    	if(canGetMoney>0){
        window.location.href = "../wallet/drawing.html?driverUuid=" + getCookie("driverUuid");
      }else{
      	alert("您当前每月可提现的金额.");	
      }
    }

    $(".eyes").click(function () {//显示密码
        if ($(this).attr("src") == "../../img/eye.png") {
            $(this).attr("src", "../../img/close-eye.png");
            $(this).prev().html('****');
        } else {
            $(this).attr("src", "../../img/eye.png");
            $(this).prev().html(totalMoneyButbzj);
        }
    })
    $("#monthShow").click(function () {
        $(".customer_popuparea").toggle();
    });
    $(document).ready(function () {
//    	var url = _global.serverHost + "/capital/driver/showCapitalList.htm";
//        var data = {monthDate: monthDate,driverUuid: getCookie("driverUuid")};
//        _callAjaxRequest(url, data, startBidBack);
//
//        function startBidBack(data) {
//        	var capitalListHtml='';
//        	var showCapitalList = data.showCapitalList;
//			if(showCapitalList==null || showCapitalList.length<1){
//				capitalListHtml='暂无信息';
//       	 	}else{
//       	 		//alert("len="+showCapitalList.length);
//       			for(var i=0;i<showCapitalList.length;i++){
//       				capitalListHtml=capitalListHtml+'<div class="twoitem"><label class="itemname">'
//       				+'<label class="itemname">'+showCapitalList[i].capitalDesc+'(订单编号 '+showCapitalList[i].waybillNum+')'
//       				+'<span class="green right">'+showCapitalList[i].amount+'</span>' 
//				    +'</label><label class="itemsubname">'+showCapitalList[i].createDate+'</label></div>';      
//				    
//       			}
//       		 	$("#capitalListHtmlId").html(capitalListHtml);
//       		 	$("#getMoney").html(data.moneyAll);
//       		 	$("#getMoneyMonth").html(data.moneyMonth);
//       		}
//        }
    });
</script>
</body>
</html>